Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

[Feature] add breakpoint machanism on SOT #240

Merged
merged 16 commits into from
Jul 5, 2023
Merged

[Feature] add breakpoint machanism on SOT #240

merged 16 commits into from
Jul 5, 2023

Conversation

2742195759
Copy link
Collaborator

动机

在 debug 的时候,如果发现模拟有问题,总是希望停在某个字节码出,并深入SOT内部查看逻辑,这类行为促使我们添加一个 breakpoint 机制。

Usage

    def forward(self, x):
        __breakpoint__ = paddle.shape(x)

        feats, shape = self.backbone(x)
        logits = self.head(feats[-1], shape[2:])
        
        logit_list = [
            F.interpolate(
                logit, __breakpoint__[2:], mode='bilinear') for logit in logits
        ]

        return logit_list

import sot
sot.add_breakpoint(__file__, 58)

这里的行号是 58。这样就会在这一行的字节码处 breakpoint 停住,后续就可以进行交互了。

@paddle-bot
Copy link

paddle-bot bot commented Jul 4, 2023

Thanks for your contribution!

f"[Translate {self._name}]: (line {self._current_line:>3}) {instr.opname:<12} {instr.argval}, stack is {self._stack}\n",
)
log_message = f"[Translate {self._name}]: (line {self._current_line:>3}) {instr.opname:<12} {instr.argval}, stack is {self._stack}\n"
log(3, log_message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里无条件打印和下面的打印是不是重复了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log3下会重复的,但是这个BM不一定在log3下使用。所以就默认都打印了一行。


def rm(self, *args, **kwargs):
# interactive use, we use abbreviate
self.breakpoints()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.breakpoints 不是 set 吗?这里直接 call 不会报错嘛?

@Aurelius84
Copy link
Collaborator

这里的行号是 58。这样就会在这一行的字节码处 breakpoint 停住,后续就可以进行交互了。

我们先借助此功能看是否可以提高模型问题的排查效率,我理解这应该是最终的调试形态,我们看如何在实践中不断优化调试机制。

@2742195759
Copy link
Collaborator Author

这个PR主要是针对 『模拟』问题,很方便的定位和了解模拟OpExecutor的执行逻辑。但是对于 Python fallback代码和生成的代码,runtime error帮助还是有限的。
runtime 问题估计需要在Paddle内部打印反向信息才好定位。

@SigureMo SigureMo merged commit 6240b70 into develop Jul 5, 2023
5 checks passed
@SigureMo SigureMo deleted the fix-resnet branch July 5, 2023 09:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants